// PictureRangeDialog.cpp : implementation file
//

#include "stdafx.h"
#include "waveeditor.h"
#include "languagecomponents.h"
#include "PictureRangeDialog.h"


// PictureRangeDialog dialog

IMPLEMENT_DYNAMIC(PictureRangeDialog, CDialog)
PictureRangeDialog::PictureRangeDialog( __int64 NewMaxEndPos, CString NewTimeType, CWnd* pParent /*=NULL*/)
	: CDialog(PictureRangeDialog::IDD, pParent)
{
	MaxEndPos = NewMaxEndPos;
	TimeType = NewTimeType;
}

PictureRangeDialog::~PictureRangeDialog()
{
}

void PictureRangeDialog::DoDataExchange(CDataExchange* pDX)
{
	CString sStartPos;
	CString sEndPos;

	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_PICT_START_POS, sStartPos);
	DDX_Text(pDX, IDC_PICT_END_POS, sEndPos);

	StartPos = CStringToLong( sStartPos );
	EndPos = CStringToLong( sEndPos );
	NormalizePositions();

}

void PictureRangeDialog::NormalizePositions()
{
	if ( StartPos > EndPos )
	{
		StartPos = StartPos^EndPos;
		EndPos = StartPos^EndPos;
		StartPos = StartPos^EndPos;
	}
	StartPos = IntervalCompare( StartPos, 0, MaxEndPos - 6 );
	EndPos = IntervalCompare( EndPos, StartPos + 6, MaxEndPos );
}

BOOL PictureRangeDialog::OnInitDialog() 
{
    CDialog::OnInitDialog();
	SetDlgItemText( IDC_STATIC_MIN_POS, "Start position: ("+TimeType+")" );
	SetDlgItemText( IDC_STATIC_MAX_POS, "End position: ("+TimeType+")" );
	SetDlgItemText( IDC_PICT_START_POS, "0" );
	SetDlgItemText( IDC_PICT_END_POS, Long64ToCString( MaxEndPos ) );
	((CEdit *)GetDlgItem( IDC_PICT_START_POS ))->LimitText ( 20 );
    ((CEdit *)GetDlgItem( IDC_PICT_END_POS ))->LimitText ( 20 );

	return TRUE;
}

__int64 PictureRangeDialog::GetStartPos()
{
	return StartPos;
}

__int64 PictureRangeDialog::GetEndPos()
{
	return EndPos;
}

BEGIN_MESSAGE_MAP(PictureRangeDialog, CDialog)
END_MESSAGE_MAP()


// PictureRangeDialog message handlers
